<style>
    #formorder{padding: 10px 5px 10px 5px;}
    #formorder input,#formorder select{margin: 5px auto;}
    #formorder button{border: 1px solid transparent;background-color: #5bc0de;color: #fff;border-radius: 3px;}
    
    .page{border-top: 1px solid #E0E0E0;padding: 5px;}
    .page .page_count{padding-top: 5px;}
    .page .page_count label{display: inline-block;line-height: 30px;font-weight: normal;float: left;}
    .page .page_count .paginate_button{
        margin: 0 5px;
        float: left;
        background-color: #D5D5D5;
        padding: 5px 12px;
        color: #7d7d7d;
        border-radius: 3px;
    }
    .page .page_count .paginate_button:hover{
        background-color: #89affc;
        color: #fff;
    }
    .page .page_count .paginate_active{
        margin: 0 5px;
        float: left;
        padding: 5px 12px;
        color: #fff;
        background-color: #89affc;
        border-radius: 3px;
    }
    
    .cz_clik a{display: inline-block;background: #89affc;color: #fff;padding: 3px 10px;border-radius: 3px;min-width: 76px;text-align: center;}
    .cz_clik a:hover{background: #89bffc;}
    
    #pop-up-boxes{
        position: fixed;width: 100%;height: 100%;z-index: 20;top: 0;left: 0;display: none;
    }
    #pop-up-boxes-content{
        width: 500px;margin: 0 auto;font-size: 14px;
        border: 1px solid black;color: black;
        margin-top: 10%;background-color: #fff;border-radius: 10px;
    }
    #pop-up-boxes-title img{
        cursor: pointer;float: right;left: 0;top: 17px;width: 16px;height: 16px;margin: 3px;border: none;border-radius: 10px;
    }
    #pop-up-boxes-text{
        padding: 20px;text-align: center;color: #555555;
    }
    #pop-up-boxes-text input{width: 250px;padding: 3px;}
	#pop-up-boxes-text select{width: 100px;padding: 3px;}
    #pop-up-boxes-text a{
        display: inline-block;
        text-align: center;
        padding: 5px 10px;
        background-color: #5bc0de;
        color: #fff;
        border-radius: 5px;
    }
    #edit input{border: 1px solid #d3d2d2;}
</style>
<section class="vbox">
    <section class="scrollable padder">
        <ul class="breadcrumb no-border no-radius b-b b-light pull-in">
            <li><a href="#"><i class="fa fa-home"></i>系统管理</a></li>
            <li><a href="#">酒店管理</a></li>
            <li><a href="#">酒店列表</a></li>
        </ul>
        <div class="m-b-md">
            <h3 class="m-b-none"><span style="float:right;"><a href="#"></a></span>酒店列表</h3>
        </div>
        <section class="panel panel-default">
            <header class="panel-heading">
                <i data-title="ajax to load the data." data-placement="bottom" data-toggle="tooltip" class="fa fa-info-sign text-muted" data-original-title="" title=""></i> 
                <b>酒店列表</b>
                <a href="javascript:;" onclick="edit(0,'')" style="float: right;border: 1px solid #5bc0de;background: #5bc0de;color: #fff;padding: 2px 5px;border-radius: 3px;">添加酒店</a>
            </header>
            <table data-ride="datatables" class="table table-striped m-b-none dataTable" id="DataTables_Table_0" >
            <thead>
                <tr role="row">
                    <th>酒店名称</th>
                    <th>酒店星级</th>
                    <th>酒店地址</th>
                    <th>状态操作</th>
                    <th>管理操作</th>
                </tr>
            </thead>
            <tbody>
            <?
            if(!empty($hotellist)){
                foreach($hotellist as $k=>$v){?>
                <tr role="row">
                    <td><?=$v['hotelName']?></td>
                    <td><?=empty($v['star'])?'无星级':($v['star'].'星级')?></td>
                    <td><?=$v['pName'].'-'.$v['cName'].'-'.$v['dName'].' '.$v['address']?></td>
                    <td>
                         <a onclick="status('<?=$v['id']?>')" class="btn btn-small btn-danger" style="padding: 2px 12px;;background-color: <?=$v['status']==1?'':'#40bf40'?>;"><?=$v['status']==1?'禁用':'使用'?></a>
                    </td>
                    <td class="cz_clik">
                        <?if($v['status']==1){?><a href="<?=$this->url("merchant/hotelLock?id=".$v['id'])?>" >管理酒店</a><?}else{echo "该酒店不能操作";}?>
                    </td>
                </tr>
                <?}
            }else{?>
                <tr><td colspan="10">没有相关内容</td></tr>
            <?}
            ?>
            </tbody>
            </table>
            <div class="page">
                <?=$pageHtml?>
            </div>
        </section>
    </section>
</section>
<a href="#" class="hide nav-off-screen-block" data-toggle="class:nav-off-screen" data-target="#nav"></a>
<div id="pop-up-boxes">
    <div id="pop-up-boxes-content">
        <div id="pop-up-boxes-title"><label>&nbsp;酒店操作</label><img src="/public/assets/sysadmin/mylzp/img/error.png" /></div>
        <div id="pop-up-boxes-text">
            <form class="form-horizontal form-bordered form-validate" action="<?=$this->url("merchant/editcategory")?>" method="post" id="edit">
                酒店名称：<input type="text" name="hotelName" id="hotelName" value="" />
                <input type="hidden" name="id" value="0" /><br /><br />
        			 <div class="controls">
                     省、市、区
                          <select name="province" style="width: 80px;">
                               <option value="0">请选择</option>
                               <?if($province){
                                     foreach($province as $k=>$v){?>
                                          <option value="<?=$v['osiiid']?>"><?=$v['name']?></option>
                                     <?}
                                }?>
                           </select>
                           <select name="city" style="width: 80px;">
                                <option value="0">请选择</option>
                           </select>
                           <select name="county" style="width: 80px;">
                                <option value="0">请选择</option>
                           </select>
                      </div><br />
                街道地址：<input type="text" name="address" id="address" value="" /><br /><br/>
                <a href="javascript:void(0);" class="show_shadefrist" onclick="isedit()" >确认操作</a>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript">
$('select[name="province"]').change(function(){
    var provinceid=$('select[name="province"] option:selected').val();
    onseleted(1,provinceid);
});
$('select[name="city"]').change(function(){
    var cityid=$('select[name="city"] option:selected').val();
    onseleted(2,cityid);
});
function onseleted(type,parentid){
    $.ajax({
        type:'post',
        url:"<?=$this->url('merchant/get_address')?>",
        data:"type="+type+"&parentid="+parentid,
        dataType:'json',
        success:function (msg){
            if(msg.type==1){
                $('select[name="city"]').html(msg.html);
                $('select[name="county"]').html("<option value='0'>请选择</option>");
            }else if(msg.type==2){
                $('select[name="county"]').html(msg.html);
            }
        },error:function(){
            pub_alert_error("ajax出现错误",2000);
        }
    });
}
$('#pop-up-boxes-title img').click(function(){
    $('#pop-up-boxes').css({'display':'none'});
});
function edit(id,title,describe){
    $('#pop-up-boxes').css({"display":"block"});
    $('#edit input[name="hotelName"]').val(title);
    $('#edit input[name="address"]').val(describe);
    $('#edit input[name="id"]').val(id);
}
function isedit(){
    $('#edit').submit();
}
function status(id){
        $.ajax({
    		type:'GET',
    		url:'<?=$this->url("merchant/status")?>',
    		data:'id='+id,
    		dataType:'json',
    		success:function(r){
    		    if(r.state==1){
    		      pub_alert_success(r.html,2000);
    		      setTimeout(function(){window.location.reload();},2000);
    		    }else if(r.state==0){
    		        pub_alert_error(r.html,2000);
    		    }
    		},
            error:function(){
                pub_alert_error("ajax出现错误",2000);
            }
    	});
}
</script>